 #ifdef __cplusplus
    #include <cstdlib>
#else
    #include <stdlib.h>
#endif
#include <SDL/SDL.h>
int main ( int argc, char** argv )
{ SDL_Event event;
  int x,y;
  SDL_Rect dstrect;
   freopen("CON","w",stdout);
   freopen("CON","r",stdin);
//printf("fdlrihf");
  // initialize SDL video
    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "Unable to init SDL: %s\n", SDL_GetError() );
        return 1;
    }
    // make sure SDL cleans up before exit
    atexit(SDL_Quit);
    // create a new window
    SDL_Surface* screen = SDL_SetVideoMode(992,600, 32,SDL_HWSURFACE|SDL_DOUBLEBUF);
    SDL_Surface* bmp = SDL_LoadBMP("ecran.bmp");
    SDL_Surface* bmp1;
    SDL_Surface* bmp2;
    SDL_Surface* bmp3;
    dstrect.x = (screen->w - bmp->w) / 2;
    dstrect.y = (screen->h - bmp->h) / 2;
     SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 255, 255, 0));
        // draw bitmap
        SDL_BlitSurface(bmp, 0, screen, &dstrect);
        // DRAWING ENDS HERE
        // finally, update the screen
        SDL_Flip(screen);
while (1)
{ while (SDL_PollEvent(&event))
{
    switch(event.type)
    {



    case SDL_MOUSEBUTTONDOWN:
       {
           x=event.motion.x;
              y=event.motion.y;

        if((x>790)&&(x<971)&&(y>231)&&(y<290))
          {
              while(1)
              {SDL_FreeSurface(bmp);

               bmp1 =SDL_LoadBMP("contour.bmp");

                SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
                SDL_BlitSurface(bmp1,0,screen,&dstrect);
                SDL_Flip(screen);
              }
          }
             if(x>815&&x<949&&y>313&&y<369)
         {
             while(1)
             {
                SDL_FreeSurface(bmp);
                bmp2 =SDL_LoadBMP("options.bmp");
                 SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
                SDL_BlitSurface(bmp2,0,screen,&dstrect);
                SDL_Flip(screen);
             }
         }
          if(x>829&&x<943&&y>398&&y<453)
         {
             while(1)
             {
                SDL_FreeSurface(bmp);
                bmp3 =SDL_LoadBMP("aide.bmp");
                 SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
                SDL_BlitSurface(bmp3,0,screen,&dstrect);
                SDL_Flip(screen);
                 if((x>950)&&(x<971)&&(y>1)&&(y<20))
          {
              while(1)
              {SDL_FreeSurface(bmp3);
                bmp =SDL_LoadBMP("ecran.bmp");

                SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
                SDL_BlitSurface(bmp,0,screen,&dstrect);
                SDL_Flip(screen);
              }
          }

             }
         }


         }


     }
       // printf ("down");
       // break;
    //case SDL_MOUSEBUTTONUP:
       // printf("up");
       // break;
    }
}
    SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 84, 37, 84));
        // draw bitmap
        SDL_BlitSurface(bmp, 0, screen, &dstrect);
        // DRAWING ENDS HERE
        // finally, update the screen
        SDL_Flip(screen);

    return 0;
}
